﻿namespace Qiao.Common.Core
{
    /// <summary>
    /// 字符串扩展方法
    /// </summary>
    public static class StringExtend
    {

        #region 字符串首字母转大写
        /// <summary>
        /// 字符串首字母转大写
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string StringToUpper(this string str)
        {
            if (string.IsNullOrWhiteSpace(str))
            {
                return str;
            }
            if (str.Length == 1)
            {
                return str.ToUpper();
            }
            return str[0].ToString().ToUpper() + str.Substring(1, str.Length - 1);
        }
        #endregion

        #region 字符串首字母转小写
        /// <summary>
        /// 字符串首字母转小写
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string StringToLower(this string str)
        {
            if (string.IsNullOrWhiteSpace(str))
            {
                return str;
            }
            if (str.Length == 1)
            {
                return str.ToLower();
            }
            return str[0].ToString().ToLower() + str.Substring(1, str.Length - 1);
        }
        #endregion

    }
}
